package app.netant.book.wanjuanba;

import org.jsoup.select.Elements;

import app.netant.book.base.BaseDetail;
/**
 * 
 * @author JiaJ
 *
 */
public class WanjuanbaDetail extends BaseDetail {

	public WanjuanbaDetail(String netSite) {
		super(netSite);
		this.preHref = "http://www.wanjuanba.com";
	}

	@Override
	public void analyseTitle() {
		Elements parts = this.select("#txt_menu h1");
		if(parts.size()>0){
			String title = parts.get(0).text();
			int idx = title.indexOf("txt");
			if(idx>0){
				title = title.substring(0,idx).trim();
			}
			System.out.println("【Title】:"+title);
			this.entity.setNovelName(title);
			this.entity.setNovelFullName(title+".txt");
		}
	}

	@Override
	public void analyseTags() {
		Elements parts = this.select("#txt_menu div");
		for(int i=0;i<parts.size();i++){
			String tags = parts.get(i).text().trim();
			if(tags.startsWith("作")){
				this.splitTags(tags, true);
			}
		}
	}

	@Override
	public void analyseMemo() {
		Elements parts = this.select("#txt_menu");
		if(parts.size()>0){
			String memo = parts.get(0).text();
			int idx = memo.indexOf("内容简介");
			if(idx>0){
				memo = memo.substring(idx+5);
				System.out.println("【Memo】:"+memo);
				this.entity.setNovelMemo(memo);
			}
		}
	}

	@Override
	public void analyseHref() {
		Elements parts = this.select("#txt_menu a.btnlink");
		if(parts.size()>0){
			String href = parts.get(0).attr("href");
			System.out.println("【Href】:"+href);
			this.entity.setDownPath(href);
		}
	}
	
	@Override
	public void analyseType() {
		
	}
	
	public static void main(String[] args) {
		WanjuanbaDetail detail = new WanjuanbaDetail("http://www.wanjuanba.com/txt/txt32041.html");
		detail.test();
	}



}
